package com.yisa.person.utils;


import sun.misc.BASE64Decoder;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class Base64Util {
    public static InputStream Base64ToInputStream(String base64string) {
        ByteArrayInputStream stream = null;
        try {
            BASE64Decoder decoder = new BASE64Decoder();
            byte[] bytes = decoder.decodeBuffer(base64string);
            for (int i = 0; i < bytes.length; ++i) {
                if (bytes[i] < 0)// 调整异常数据
                {
                    bytes[i] += 256;
                }
            }
            //转化为输入流
            stream = new ByteArrayInputStream(bytes);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return stream;
    }
}